goog.require('dkpoints.ServiceProvider');

goog.require('goog.testing.jsunit');


var auth, rpc, status, bodyContent, sp;


var setUp = function() {
  auth = {};
  rpc = {};
  status = {};
  bodyContent = document.getElementById('body_content');
  sp = new dkpoints.ServiceProvider(auth, rpc, status, bodyContent);
};


/**
 * Test that ServiceProvider properly stores and returns its fields.
 */
var testStoresAndReturnsFields = function() {
  assertEquals('getAuth should return the given auth instance.',
               auth, sp.getAuth());
  assertEquals('getRPC should return the given rpc instance.',
               rpc, sp.getRPC());
  assertEquals('getStatusManager should return the given status instance.',
               status, sp.getStatusManager());
  assertEquals('getBodyContent should return the given bodyContent reference.',
               bodyContent, sp.getBodyContent());
};


/**
 * Test getter and setter for baseURL.
 */
var testGetSetBaseURL = function() {
  var url = 'http://dkpoints.appspot.com';
  sp.setBaseURL(url);

  assertEquals('sp.baseURL_ should equal ' + url, url, sp.baseURL_);
  assertEquals('sp.getBaseURL should return ' + url, url, sp.getBaseURL());
};


/**
 * Test getter and setter for Nav Manager.
 */
var testGetSetNavManager = function() {
  var nav = {};
  sp.setNavManager(nav);

  assertEquals('sp.navManager_ should be the given nav object.',
               nav, sp.nav_);
  assertEquals('sp.getNavManager should return the given nav object.',
               nav, sp.getNavManager());
};


var tearDown = function() {
  sp = null;
};
